﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using TTGame;
using UnityEditor;

/*
 * TestAnimStuffEditor
 *
 *
 *
 * 依赖：
 *
 * ！不写重复代码！
 * @author TTun
 * @date 7/20/2017 9:36:35 AM
 */
[CustomEditor(typeof(TestAnimStuff))]
public class TestAnimStuffEditor : Editor {

    private SerializedObject scriptObj;
    private SerializedProperty animProp;
    TestAnimStuff obj;

    public void OnEnable() {
        scriptObj = new SerializedObject(target);
        obj = target as TestAnimStuff;
        animProp = scriptObj.FindProperty("anim");
    }

    Queue<string> historyNames = new Queue<string>();
    public override void OnInspectorGUI() {
        scriptObj.Update();

//         if(GUILayout.Button("PlayAnimWithLayer")) {
//             obj.PlayAnimWithLayer();
//         }
        if(GUILayout.Button("RewindAllAnim")) {
            obj.RewindAllAnim();
        }
//         if(GUILayout.Button("CrossFadeAnim")) {
//             obj.CrossFadeAnim();
//         }
        if(GUILayout.Button("PlayAnim")) {
            obj.PlayAnim();
        }
        if(GUILayout.Button("RefreshAnimStateInfo")) {
            obj.RefreshAnimInfo();
        }
//         if(GUILayout.Button("Save Name")) {
//             if(false == historyNames.Contains(obj.m_playAnimName) &&
//                     obj.anim[obj.m_playAnimName] != null) {
//                 historyNames.Enqueue(obj.m_playAnimName);
//             }
//             if(historyNames.Count > 10) {
//                 historyNames.Dequeue();
//             }
//         }
//         EditorGUILayout.BeginHorizontal();
//         foreach(string name in historyNames) {
//             if(GUILayout.Button(name)) {
//                 obj.m_playAnimName = name;
//             }
//         }
//         EditorGUILayout.EndHorizontal();
        base.OnInspectorGUI();
        scriptObj.ApplyModifiedProperties();

        //clip的具体信息
        EditorGUILayout.BeginVertical("HelpBox");
        GUILayout.Label(obj.DumpEnabledAnimStateInfo());
        EditorGUILayout.EndVertical();


    }

}
